#include "defs.h" 
#include "riscv.h"

uint64_t sbi_call(uint64_t sbi_type, uint64_t arg0, uint64_t arg1, uint64_t arg2) {
    uint64_t ret_val;
    __asm__ volatile ( 
        "mv a0, %[op0]\n\t"
	"mv a1, %[op1]\n\t"
	"mv a2, %[op2]\n\t"
	"mv a7, %[type]\n\t"
	"ecall\n\t"
	:[a0]"=r"(ret_val)
	:[type]"r"(sbi_type), [op0]"r"(arg0), [op1]"r"(arg1), [op2]"r"(arg2)
   );
    return ret_val;
}


void trigger_time_interrupt(unsigned long long stime_value) {
    sbi_call(0, stime_value, 0, 0);
}
